{% extends "erp/base.html" %}

{% block title %}产品库存{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-12">
        <h2>产品库存查询</h2>
        
        <div class="search-box">
            <form method="get" class="row g-3">
                <div class="col-md-8">
                    <input type="text" class="form-control" name="search" placeholder="输入产品SKU搜索..." value="{{ search_query }}">
                </div>
                <div class="col-md-2">
                    <button type="submit" class="btn btn-primary">搜索</button>
                </div>
                <div class="col-md-2">
                    <a href="{% url 'product_inventory' %}" class="btn btn-secondary">重置</a>
                </div>
            </form>
        </div>
        
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                    <tr>
                        <th>SKU</th>
                        <th>总PCS数</th>
                        <th>总箱数</th>
                        <th>箱规 & 箱数</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in inventory_data %}
                    <tr>
                        <td>{{ item.sku }}</td>
                        <td>{{ item.total_pcs }}</td>
                        <td>{{ item.total_boxes }}</td>
                        <td>{{ item.box_details|join:" & " }}</td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="4" class="text-center">没有找到匹配的产品库存数据</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}